package com.dwxt.stadium.controller;

import com.dwxt.common.annotation.ValidateFiled;
import com.dwxt.common.annotation.ValidateGroup;
import com.dwxt.common.base.BaseResult;
import com.dwxt.stadium.service.StadiumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 动美场馆预定
 */
@RequestMapping("/stadium")
@RestController
public class StadiumController {

    @Autowired
    private StadiumService stadiumService;

    /**
     * showdoc
     *
     * @param startTime           必选 string 开始时间
     * @param endTime             必选 string 结束时间
     * @param productIds          必选 List 产品id的集合
     * @param onlinePaymentMethod 必选 int 支付方式(0:支付宝,1:微信)
     * @return {"status":200,"msg":"SUCCESS","data":{"IsFullPayment":false,"IsPartialPayment":true,"IsBlancePaymentSuccess":false,"RequestId":"5262aa13-d0af-4aa7-8c63-cea9c6f48658","AliPrePaystr":null,"WeiXinPrepayId":"wx1714391078826679425f7c881014919100","orderId":"1231231313123"}}
     * @catalog 商城/动美场馆
     * @title 预定场馆
     * @description 预定场馆
     * @url /stadium/bookStadium
     */
    @RequestMapping("/bookStadium")
    @ValidateGroup(fileds = {
            @ValidateFiled(index = 0, notNull = true),
            @ValidateFiled(index = 1, notNull = true),
            @ValidateFiled(index = 2, notNull = true),
            @ValidateFiled(index = 3, notNull = true),
    })
    public BaseResult bookStadium(String startTime, String endTime, String productIds,
                                  Integer onlinePaymentMethod) throws Exception {
        return stadiumService.bookStadium(startTime, endTime, productIds, onlinePaymentMethod);
    }


    @RequestMapping("/bookStadiumDiff")
    public BaseResult bookStadiumDiff(String startTimes, String endTimes, String productIds,
                                      Integer onlinePaymentMethod, Double fee, String companyId, String memberId) throws Exception {
        return stadiumService.bookStadiumDiff(startTimes, endTimes, productIds, onlinePaymentMethod, fee, companyId, memberId);
    }

    /**
     * showdoc
     *
     * @param orderId 必选 string 订单id
     * @param reason  可选 string 退款理由
     * @return {"status":200,"msg":"SUCCESS","data":null}
     * @catalog 商城/动美场馆
     * @title 申请退款
     * @description 申请退款
     * @url /stadium/refund
     */
    @RequestMapping("/refund")
    @ValidateGroup(fileds = {
            @ValidateFiled(index = 0, notNull = true),
    })
    public BaseResult refund(String orderId, String reason) {
        return stadiumService.refund(orderId, reason);
    }



    @RequestMapping("/selectCard")
    public BaseResult selectCard(String companyId,String userId){
        return stadiumService.selectCard(companyId,userId);
    }
}
